<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resource/template/plantilla.xhtml">

        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="person.publisher.label_es" var="label" />
                <f:loadBundle basename="person.publisher.message_es" var="message" />
                <f:loadBundle basename="person.publisher.help_es" var="help" />
                <script>
                    function verificar(dato)
                    {
                        var agree = confirm(dato);
                        if (agree)
                            return true;
                        else
                            return false;
                    }
                </script>
            </h:head>
        </ui:define>

        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <h:body>
                <h:outputText value="#{message.m0}" class="label" rendered="#{!access.visit}"/>
                <h:form rendered="#{access.visit}">  
                    <p:growl id="messages" showDetail="true"/>  
                    <div class="field">
                        <h:outputText value="#{label.field8}" class="label"/>
                        <h:selectOneMenu value="#{person_publisher.id_pais}" required="#{param['required']=='true'}" requiredMessage="#{message.m21}" >
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItems value="#{location_countryFind.listItem()}" />  
                        </h:selectOneMenu>
                        <h:commandButton class="addButton" onclick="addPais.show()" type="button"/>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field1}" class="label"/>
                        <h:selectOneMenu  value="#{person_publisher.idl_Tipo}" required="#{param['required']=='true'}" requiredMessage="#{message.m22}">  
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItem itemLabel="#{label.tipo1}" itemValue="1" />  
                            <f:selectItem itemLabel="#{label.tipo2}" itemValue="2" />
                            <f:selectItem itemLabel="#{label.tipo3}" itemValue="3" />
                            <f:selectItem itemLabel="#{label.tipo4}" itemValue="4" />  
                            <f:selectItem itemLabel="#{label.tipo5}" itemValue="5" />
                        </h:selectOneMenu>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field2}" class="label"/>
                        <h:selectOneMenu value="#{person_publisher.idl_Rol}" required="#{param['required']=='true'}" requiredMessage="#{message.m23}"> 
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItem itemLabel="#{label.rol1}" itemValue="1" />  
                            <f:selectItem itemLabel="#{label.rol2}" itemValue="2" />
                        </h:selectOneMenu>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field3}" class="label"/>
                        <h:selectOneMenu value="#{person_publisher.idl_Disciplina}" required="#{param['required']=='true'}" requiredMessage="#{message.m24}">  
                            <f:selectItem itemLabel="" itemValue=""/>
                            <f:selectItem itemLabel="#{label.disciplina1}" itemValue="1" />  
                            <f:selectItem itemLabel="#{label.disciplina2}" itemValue="2" />
                            <f:selectItem itemLabel="#{label.disciplina3}" itemValue="3" />
                        </h:selectOneMenu>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field4}" class="label"/>
                        <p:calendar value="#{person_publisher.fecha}" effect="slide" navigator="true" readonlyInput="true" pattern="dd/MM/yy" size="5"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field5}" class="label"/>
                        <h:inputText value="#{person_publisher.titulo}" class="textfield" required="#{param['required']=='true'}" requiredMessage="#{message.m25}" size="45"/>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field6}" class="label"/>
                        <h:inputText value="#{person_publisher.editorial}" class="textfield" required="#{param['required']=='true'}" requiredMessage="#{message.m26}" size="40"/>
                        <h:outputText class="required" value="*"/>
                    </div>

                    <div class="field">
                        <h:outputText value="#{label.field7}" class="label"/>
                        <h:inputText value="#{person_publisher.colaborador}" class="textfield"/>
                    </div>

                    <h:commandButton value="#{label.button1}" class="button" actionListener="#{person_publisher.insert()}" rendered="#{access.add}" onclick="return verificar('#{message.m7}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <h:commandButton value="#{label.button2}" class="button" actionListener="#{person_publisher.update}" rendered="#{access.update}" onclick="return verificar('#{message.m8}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <h:commandButton value="#{label.button3}" class="button" actionListener="#{person_publisher.delete}" rendered="#{access.delete}" onclick="return verificar('#{message.m9}')"/>
                    <h:commandButton value="#{label.button4}" class="button" actionListener="#{person_publisher.clear}"/>
                    <!--<h:commandButton value="#//{label.button5}" action="/faces/page/person/list.xhtml" actionListener="#//{person.find}"/>-->

                    <!--Dialogos para la insertcion de pais-->
                    <p:dialog id="addPais" widgetVar="addPais" header="#{label.title2}" modal="true" resizable="false" >
                        <h:inputText value="#{person_publisher.countryBeans.nombre}" class="textfield"/>
                        <h:commandButton value="#{label.button1}" class="button" actionListener="#{person_publisher.insertCountry}" onclick="addPais.hide();"/>
                    </p:dialog>

                </h:form>

                <h:form>
                    <c:set var="list" value="#{person_publisherFind.listByLoggedId}"/>
                    <h:panelGroup layout="block" class="tableWrapper" rendered="#{not empty list}">
                        <h:dataTable var="p" value="#{list}" class="dataTable">
                            <h:column>
                                <f:facet name="header"></f:facet>
                                <h:commandLink styleClass="editButton" actionListener="#{person_publisher.selectedTempId(p.id)}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{label.field4}</f:facet>
                                <h:outputText value="#{p.fecha}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{label.field6}</f:facet>
                                <h:outputText value="#{p.editorial}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field8}</f:facet>
                                <h:outputText value="#{p.countryBeans.nombre}"/>
                            </h:column>

                            <h:column>
                                <f:facet name="header">#{label.field1}</f:facet>
                                <c:set var="tipo" value="tipo#{p.idl_Tipo}" />
                                <h:outputText value="#{label[tipo]}"/>
                            </h:column>

                            <h:column>
                                <f:facet name="header">#{label.field3}</f:facet>
                                <c:set var="disciplina" value="disciplina#{p.idl_Disciplina}" />
                                <h:outputText value="#{label[disciplina]}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{label.field5}</f:facet>
                                <h:outputText value="#{p.titulo}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{label.field2}</f:facet>
                                <c:set var="rol" value="rol#{p.idl_Rol}" />
                                <h:outputText value="#{label[rol]}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{label.field7}</f:facet>
                                <h:outputText value="#{p.colaborador}"/>
                            </h:column>


                        </h:dataTable>
                    </h:panelGroup>
                </h:form>
            </h:body>
        </ui:define>

        <!--Segemento donde se define un texto de ayuda para que el usuario pueda utilizar el formulario del contenido-->
        <ui:define name="slideHelper">
            <h3>#{help.title1} </h3>
            #{help.detail1a}
            <p>
                #{help.title2}
                <ul>
                    <li>#{help.detail2a}</li>
                    <li>#{help.detail2b}</li>
                </ul> 
                #{help.title3}
                <ul>
                    <li>#{help.detail3a}</li>
                    <li>#{help.detail3b}</li>
                </ul>
            </p>
        </ui:define>
    </ui:composition>
</html>
